#include "inputfield.h"

InputField::InputField(QWidget *parent) :
    QLineEdit(parent)
{
    QRegExp regexp("([0-9]{0,2})");
    this->setValidator(new QRegExpValidator(regexp,this));

    connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkIfValid(QString)));
}

void InputField::checkIfValid(QString numberInField)
{
    if (numberInField.toInt() > 34)
        this->setStyleSheet("QLineEdit {background-color: red;}");
    else if (numberInField.toInt() == 0)
        this->clear();
    else
        this->setStyleSheet("QLineEdit {background-color: white;}");
}

void InputField::checkIfValid2()
{
    if (this->text().toInt() > 34)
        this->setStyleSheet("QLineEdit {background-color: red;}");
}
